#include "yymeshtypes.h"


int YYMesh::computeTriangleCount() { 
	int sum = 0; for (int i = 0; i < _prims.size(); ++i)sum += _prims[i]._faces.size(); return sum;
}
void YYMesh::computeBbox(vec3d& bbmin, vec3d& bbmax)
{
	bbmin.x = bbmin.y = bbmin.z = 9999.0;
	bbmax.x = bbmax.y = bbmax.z = -9999.0;
	if (_prims.size() == 0)return; 
	bbmin = _prims[0].bboxmin;
	bbmax = _prims[0].bboxmax;
	for (int i = 1; i < _prims.size(); ++i) {
		bbmin.x = fmin(bbmin.x, _prims[i].bboxmin.x);
		bbmin.y = fmin(bbmin.y, _prims[i].bboxmin.y);
		bbmin.z = fmin(bbmin.z, _prims[i].bboxmin.z);

		bbmax.x = fmax(bbmax.x, _prims[i].bboxmax.x);
		bbmax.y = fmax(bbmax.y, _prims[i].bboxmax.y);
		bbmax.z = fmax(bbmax.z, _prims[i].bboxmax.z);
	}
}